package b4.model.player
{
	import b4.model.basic.*;
	
	public class PlayerManager extends Model
	{
		//普通用户
		public static const NORMAL_TYPE:int = 0;
		//管理员
		public static const MANAGER_TYPE:int = 10;
		//中心商圈
		public static const CENTER_TYPE:int = 20;
		//联盟
		public static const UNION_TYPE:int = 30;
		
		//用户本人的ID
		private var myOpenId:String;
		//所有的玩家（id => Player）
		private var players:Object;
		
		static private var instance:PlayerManager;
		
		public function PlayerManager()
		{
			super();
			players = new Object();
		}
		
		static public function getInstance():PlayerManager
		{
			if (!instance)
				instance = new PlayerManager();
			return instance;
		}
		
		public function get me():Me
		{
			return players[myOpenId] as Me;
		}
		
		public function registerPlayer(player:Player):void
		{
			players[player.openId] = player;
		}
		
		public function registerMe(me:Me):void
		{
			players[me.openId] = me;
			myOpenId = me.openId;
		}
		
		public function getPlayerById(id:int):Player
		{
			return players[id]; 
		}
		
	}
}